<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="common/include :: header('请假流程审核')" />
</head>
<body class="gray-bg">
<div class="container-div">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="post-form">
				<div class="select-list">
					<ul>
						<li class="select-time">
							<label>创建时间：</label>
							<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="startTime"/>
							<span>-</span>
							<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="endTime"/>
						</li>
						<li>
							状态：
							<select name="status" th:with="type=${@dict.getType('bus_type')}">
								<option value="">所有</option>
								<option th:each="dict : ${type}" th:text="${dict.label}" th:value="${dict.value}"></option>
							</select>
						</li>
						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>

		<div class="btn-group-sm" id="toolbar" role="group">
			
			<a class="btn btn-success" id="startAudit" onclick="startAudit()">
				<i class="fa fa-plus"></i> 发起审核
			</a>

		</div>

		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table"></table>
		</div>
	</div>
</div>
<th:block th:include="common/include :: footer" />
<script th:inline="javascript">
	var editFlag = [[${@permission.hasPermi('system:busLeave:edit')}]];
	var removeFlag = [[${@permission.hasPermi('system:busLeave:remove')}]];
	var statusDatas = [[${@dict.getType('bus_type')}]];
	var prefix = ctx + "/business/busLeave";
	$(function() {
		var options = {
			url: prefix + "/query",  			 		//查询的url
			removeUrl: prefix + "/remove",				//删除的地址
			modalName: "请假详情",							//模态框的名称
			columns: [{
				checkbox: true
			},
				{
					field: 'id',
					title: '请假id',
					visible: false//是否隐藏id
				},
				{
					field: 'name',
					title: '用户名称',
					sortable: true
				},
				{
					field: 'reason',
					title: '请假原因',
					sortable: true
				},
				{
					field: 'starttime',
					title: '开始时间',
					sortable: true
				},
				{
					field: 'endtime',
					title: '结束时间',
					sortable: true
				},
				{
					field: 'auditor.userName',
					title: '审核人名称',
					sortable: true
				},
				{
					field: 'status',
					title: '状态',
					sortable: true,
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(statusDatas, value);
					}
				}]
		};
		$.table.init(options);
	});

	//发起审核的逻辑判断
	//当选中一个，取消一个，选中全部，不选中全部
	// $('#bootstrap-table').on('check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table', function () {
	// 	//获取选中的数据
	// 	var rows = $('#bootstrap-table').bootstrapTable('getSelections');
	// 	//判断选中数据的个数，若是个数大于1 或者 等于0让按钮变灰
	// 	if (rows.length > 1 || rows.length == 0) {
	// 		$('#startAudit').addClass("disabled");
	// 		return;
	// 	}
	// 	//判断数据的套餐情况,若是非套餐，让按钮变灰
	// 	var row = rows[0];
	// 	//判断数据的审核状态，若审核状态为审核中或者审核通过的状态那么让按钮变灰
	// 	if (row.auditStatus == 1 || row.auditStatus == 2) {
	// 		$('#startAudit').addClass("disabled");
	// 		return;
	// 	}
	// 	//去除disabled
	// 	$('#startAudit').removeClass("disabled");
	// });

	//点击发起审核按钮，传入id
	function startAudit() {
		$.modal.open("审核详情","/business/busLeave/auditPage");
	}
</script>
</body>
</html>